// 使用示例
loadScript('https://11wan.yy.com/s/h5_sdk/gameH5Sdk.js', function(err) {
    if (err) {
        console.error('加载出错');
    } else {
        console.log('加载成功');
        // 在这里使用加载的库
        // 初始化
        WanGameH5sdk.config({
            share: {    // 邀请参数配置
                success: function() {
                    // 邀请成功
                },
                cancel: function() {
                    // 取消邀请
                }
            },
            focus: {   // 关注状态配置
                success: function() {
                    // 异步通知关注成功
                }
            }
        });
        // 登录接口
        WanGameH5sdk.login({
            success: function(data) {
                data.cid = cid;
                data.gid = gid;
                // 登录成功回调
                console.log(data);
                faXingLogin(data);

            },
            fail: function(data) {
                // 登录失败回调
                console.log(data.status); // 失败状态码
            }
        });
    }
});



function YY_creterole(data){
    console.log("YY发行角色创建：",data);
    if(!open_game){
        open_game = 1;
        WanGameH5sdk.log({
            action: 'access',
            gser: data.sid,
            servername: data.sid,
            roleid: data.role_id,
            rolename: data.role_name,
            rolelevel: data.role_level,
        });
    }
    if(data.role_level > 1){
        WanGameH5sdk.log({
            action: 'levelup',
            actionvalue:data.role_level,
            gser: data.sid,
            servername: data.sid,
            roleid: data.role_id,
            rolename: data.role_name,
            power: data.role_power,
        });
    }else{
        WanGameH5sdk.log({
            action: 'createrole',
            gser: data.sid,
            servername: data.sid,
            roleid: data.role_id,
            rolename: data.role_name,
            rolelevel: data.role_level,
            isvip: '0',
            viplevel: '0',
            power: data.role_power,
            newuser: '1'
        });
    }
}


function YY_pay(data){
    WanGameH5sdk.placeOrder(data);
}
